from fastapi import APIRouter
from fastapi.responses import HTMLResponse


# 配置文件：DbConfig
class FastapiConfig:
    debug = True
    title = 'FastAPI 项目接口文档'
    description = '基于FastAPI的模板工程'
    version = '0.0.1.20201126'
    openapi_url = '/openapi.json'
    openapi_prefix = ''
    docs_url = '/docs'  # 系统自带接口文档
    redoc_url = '/redoc'
    swagger_ui_oauth2_redirect_url = '/docs/oauth2-redirect'
    swagger_ui_init_oauth = None
    res_path = 'static'
    request_log_to_mongo = True


base_router = APIRouter()


@base_router.get('/', response_class=HTMLResponse, summary='访问根路径')
async def get_root():
    return """
        <!DOCTYPE html>
        <html>
            <head>
                <title>FastAPI Link</title>
                <style>body  {display:  flex;flex-direction:  column;justify-content:  center;
                    align-items:  center;height:  100vh;text-align:  center;}</style>
            </head>
            <body>
                <h1>欢迎来到FastApi极速开发系统</h1>
                <a href="http://127.0.0.1:8000/docs">FastApi 接口文档</a>
            </body>
        </html>
    """
